/*
 * �쐬��: 2008/07/31
 *
 * ���̐������ꂽ�R�����g�̑}����e���v���[�g��ύX���邽��
 * �E�B���h�E > �ݒ� > Java > �R�[�h���� > �R�[�h�ƃR�����g
 */
package sort;

import sort.algorithm.BubbleSort;
import sort.algorithm.Sorter;
import sort.record.FixedRecordsFactory;
import sort.record.Records;
import sort.record.RecordsFactory;
import sort.testutils.SortingPrinter;

/**
 * @author masaru-gotou
 *
 */
public class SortMain extends SortingPrinter {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SortMain main = new SortMain();
		main.go();
	}

	private void go() {
		RecordsFactory factory = FixedRecordsFactory.getInstance();
		
		Records recs = factory.create(100);
		int n = recs.size();
		
		Sorter sorter = new BubbleSort();
//		Sorter sorter = new InsertionSort();
		sorter.addObserver(this);
		
		System.out.println("original");
		print(recs);
		long start = System.currentTimeMillis();
		Records sorted = sorter.sort(recs.copy());
		long end = System.currentTimeMillis();
		
		System.out.println("sorted");
		print(sorted);
		System.out.println("atomicity="+sorted.containsAll(recs));
		System.out.println("elapsed time="+(end-start)+"msec");
		System.out.println("n="+n);
	}
}
